<?php
class App_Module_Admin_Component_Service_Ctrl_Http_Web extends App_Module_Admin_Component_Service_Ctrl_Http
{
    protected function PrimaryActionInit ($basicActionName)
    {
        Mozg::Layout('admin')->SetMenuActiveElement('cfg/service');
    }
        
    /**
		экшен по-умолчанию
	*/
    public function PrAction ()
    {
        $this->outPr();
    }

    public function outPrAction ()
    {
        $t = $this->GetTpl('Web');
        Mozg::Response('http')->SetBody($t->OutService());
    }
    
    public function delete_html_cachePrAction()
    {
        if (!$this->DeleteHTMLCache())
        {
            Mozg::Lib('messanger')->createMessage(Mozg_Lang::_('ERROR_WHILE_EMPTY_HTML_CACHE'), MESSAGE_ERROR);
        }
        else
        {
            Mozg::Lib('messanger')->createMessage(Mozg_Lang::_('HTML_CACHE_EMPTY'));
        }
        
       	Mozg_Router::Get('http')->Redirect(array('module' => 'admin', 'ctrl' => 'service'));
    }
    
    public function delete_css_cachePrAction()
    {
        if (!$this->DeleteCSSCache())
        {
            Mozg::Lib('messanger')->createMessage(Mozg_Lang::_('ERROR_WHILE_EMPTY_CSS_CACHE'), MESSAGE_ERROR);
        }
        else
        {
            Mozg::Ctrl('media', 'style', 'http', 'web')->UpdateStyleRevision('css');
            Mozg::Lib('messanger')->createMessage(Mozg_Lang::_('CSS_CACHE_EMPTY'));
        }
        
        Mozg_Router::Get('http')->Redirect(array('module' => 'admin', 'ctrl' => 'service'));
    }

    public function delete_js_cachePrAction()
    {
        if (!$this->DeleteJSCache())
        {
            Mozg::Lib('messanger')->createMessage(Mozg_Lang::_('ERROR_WHILE_EMPTY_JAVASCRIPT_CACHE'), MESSAGE_ERROR);
        }
        else
        {
            Mozg::Ctrl('media', 'style', 'http', 'web')->UpdateStyleRevision('js');
            Mozg::Lib('messanger')->createMessage(Mozg_Lang::_('JAVASCRIPT_CACHE_EMPTY'));
        }
        
        Mozg_Router::Get('http')->Redirect(array('module' => 'admin', 'ctrl' => 'service'));
    }

    public function delete_tmp_cachePrAction()
    {
        if (!$this->DeleteTMPCache())
        {
            Mozg::Lib('messanger')->createMessage(Mozg_Lang::_('ERROR_WHILE_EMPTY_TMP_CACHE'), MESSAGE_ERROR);
        }
        else
        {
            Mozg::Lib('messanger')->createMessage(Mozg_Lang::_('TMP_CACHE_EMPTY'));
        }
        
        Mozg_Router::Get('http')->Redirect(array('module' => 'admin', 'ctrl' => 'service'));
    }
}